home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / swtools / generic / pulldown.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.3 KB  |  80 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. #include <gl.h>
  19. #include <device.h>
  20. #include "generic.h"
  21. #include "showcaseui.h"
  22.  
  23. /* pulldown.c makes a pull-down menu bar across the top of the
  24.  * application.  It has a File menu and a Help menu.  In addition, 
  25.  * it has an Edit menu with one 'Touch' entry for the benefit of
  26.  * the generic application.  If you don't want a pull-down, get
  27.  * rid of this file, and the external calls to makepulldown(), 
  28.  * remakepulldown(),  and to pulldonwevent();
  29.  */
  30.  
  31. #define MENUCOUNT   3
  32.  
  33. static PullDown    *menu[MENUCOUNT];
  34. static MenuBar  *mb = 0;
  35.  
  36. long uiinited = 0;  /* in case you're using libui.a */
  37.  
  38. void makepulldown()
  39. {
  40.     if (!uiinited) {
  41.         uiinited = 1;
  42.     initui();
  43.     }
  44.     initpd();
  45.     if (mb == 0) mb = newmenubar();
  46.     menu[0] = newpd(mb, "File");
  47.     menu[1] = newpd(mb, "Edit");
  48.     menu[2] = newpd(mb, "Help");
  49.     loadpd(menu[0],"New%x100001%an|Open ...%x100002%ao|Save ...%x100003%as|Save As ...%x100004%aS|Insert ...%x100005|Print%x100006%ap|Quit%x100007%aq");
  50.     loadpd(menu[1],"Touch File %x100009");
  51.     loadpd(menu[2],"Help%x8");
  52.     loadmenubar(mb, MENUCOUNT, menu);
  53. }
  54.  
  55. void drawpulldown()
  56. {
  57.     pushviewport();
  58.     viewport(0, (short)(xsize - 1), 0, (short)(ysize - 1));
  59.     savemat();
  60.     ortho2(-0.5, xsize-0.5, -0.5, ysize-0.5);
  61.     if (mb) drawmenubar(mb);
  62.     restoremat();
  63.     popviewport();
  64. }
  65.  
  66. long pulldownevent(long mx, long my)
  67. {
  68.     long selection;
  69.     if (inmenubar(mb, mx, my) != -1) {
  70.         selection = dopulldown(mb);
  71.     return selection;
  72.     }
  73.     return -1;
  74. }
  75.  
  76. void remakepulldown()
  77. {
  78.     if (mb) movemenubar(mb);
  79. }
  80.